package thread;

import java.util.Scanner;

public class Demo25 {

    public static Object locker = new Object();

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            System.out.println("wait 前");
           synchronized (locker) {
               try {
                   locker.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
            System.out.println("wait 后");
        });
        Thread t2 = new Thread(() -> {
            System.out.println("t2 notify 之前");
            Scanner scanner = new Scanner(System.in);
            scanner.next();
            synchronized (locker) {
                locker.notify();
            }
            System.out.println("t2 notify 之后");
        });
        t1.start();
        t2.start();
    }
}
